#include <iostream>
#include <string>

template <class T1, class T2>
class Person
{
public:
    Person(T1 name, T2 age)
    {
        this->m_Name = name;
        this->m_Age = age;
    }

    void showPerson()
    {
        std::cout << "name:" << this->m_Name << " age:" << this->m_Age << std::endl;
    }
    T1 m_Name;
    T2 m_Age;
};

// 三种方式传递类模板对象做函数参数
// 1.指定传入类型
void printPerson(Person<std::string, int> &p)
{
    p.showPerson();
}

void test01()
{
    Person<std::string, int> p1("jack", 18);
    printPerson(p1);
}

// 2.参数模板化
template <class T1, class T2>
void printPerson2(Person<T1, T2> &p)
{
    p.showPerson();
}

void test02()
{
    Person<std::string, int> p2("rose", 20);
    printPerson2(p2);
}

// 3.整个类模板化
template <class T>
void printPerson3(T &p)
{
    p.showPerson();
}
 
void test03()
{
    Person<std::string, int> p3("mike", 22);
    printPerson3(p3);
}

int main()
{
    test01();
    test02();
    test03();
    return 0;
}